/*
*已知有如下string对象：string generic1("Dear Ms Daisy:"); string generic2("MrsMsMissPeople");
*编写程序实现下面函数
*string greet(string form,string lastname,string title,string::size_type pos,int length);
*该函数实现如下功能：对于字符串form,将其中的Daisy替换为lastname,将其中的Ms替换为字符串title中从pos下标开始的length个字符。
*/
#include <iostream>
#include <string>
using namespace std;

string greet(string form,string lastname,string title,string::size_type pos,int length);

int main()
{
	string generic1("Dear Ms Daisy"); 
	string generic2("MrsMsMissPeople");
	string result = greet(generic1,"Tom",generic2,0,3);
	cout << result << endl;
	system("pause");
	return 0;
}

string greet(string form,string lastname,string title,string::size_type pos,int length)
{
	string result = form.replace(8,5,lastname); 
	result.replace(5,2,title.substr(pos,length));
	return result;
}